import React,{Component} from 'react'
import CommentInput from "./CommentInput"
import CommentList from "./CommentList"
import './Comment.css'

class Comment extends Component {
  constructor() {
    super()
    this.state = {
      items : [
        {
          name: 'Tom',
          cont: '一人之下很好看哦，你可以去瞧一瞧'
        },
        {
          name: 'Jani',
          cont: '是吗，我今天下班看看'
        },
        {
          name: 'Tom',
          cont: '你最近发现什么好看的动漫吗？'
        },
        {
          name: 'Jani',
          cont: '有一部，名字是 迷域行者，国漫，值得一看'
        }
      ]
    }
  }
  render() {
    return (
      <div className="comment">
        <CommentInput onSubmit={this.handleSubmit.bind(this)}/>
        <CommentList items={this.state.items}/>
      </div>
    )
  }
  handleSubmit(comment) {
    console.log(comment);
    let items = this.state.items
    items.push(comment)

    this.setState({
      items: items
    })
  }
}

export default Comment